package consistentHash;

/**
 * @author 03010570
 * @date 2020/07/07
 * describe:    虚拟节点
 */
public class VirtualNode {
    private PhysicalNode physicalNode;
    private Integer replicaIndex;

    public VirtualNode(PhysicalNode physicalNode, Integer replicaIndex) {
        this.physicalNode = physicalNode;
        this.replicaIndex = replicaIndex;
    }

    public boolean matches(String name) {
        return physicalNode.toString().equalsIgnoreCase(name);
    }

    @Override
    public String toString() {
        return physicalNode.toString().toLowerCase() + ":" + replicaIndex;
    }

    public PhysicalNode getPhysicalNode() {
        return physicalNode;
    }

    public void setPhysicalNode(PhysicalNode physicalNode) {
        this.physicalNode = physicalNode;
    }

    public Integer getReplicaIndex() {
        return replicaIndex;
    }

    public void setReplicaIndex(Integer replicaIndex) {
        this.replicaIndex = replicaIndex;
    }
}
